//社区 页面
import Avatar from '../users/Me/Avatar';
import React, { Component } from 'react'
import { withRouter } from "react-router-dom";
import { getdynamic, getMsg } from '../redux/actionCreator';
import Mytab from './Mytab'
import imgInter from '../data/Interface'
import { connect } from 'react-redux'
import Position from './Home/Position';
import MyListView from './Dynamic/MyListView';
import pxPage from '../root/pxPage';
// import './Dynamic/dynaic.css'
class Community extends Component {
    constructor(props) {
        super(props)
        this.state = {

        }
        // console.log(this.props)
        this.props.dispatch(getdynamic())
    }
    render() {
        const { dynamic } = this.props
        return (
            <div style={{ minHeight: '100vh', display: 'flex' }}>
                <div style={{ backgroundColor: "#080904", minHeight: '100vh', display: 'flex', width: '100%' }}>
                    {/* <Position /> */}
                    <div
                        // 点击跳转到最上方
                        onClick={() => {
                            window.scrollTo(0, 0)
                        }}
                        style={{ width: '100%', backgroundColor: '#33273D', position: 'fixed', top: '0', height: '70px', zIndex: '3' }}
                    >
                        {/* 左边的个人信息 */}
                        <div style={{ width: '90%' }}>
                            {/* 头像 */}
                            <div
                                onClick={() => { this.props.history.push('/me') }}
                                style={{ position: 'absolute', left: '5%', top: '15px', height: '3.5em', width: '3.5em', border: '1px solid #fff', borderRadius: '50%' }}>
                                <img style={{ height: '3.5em', width: '3.5em', borderRadius: '50%' }} src={`http://www.h5weixin.club:1025/api/image/${JSON.parse(localStorage.getItem('user')).user_pic}`}></img>
                            </div>
                            <span
                                onClick={() => { this.props.history.push('/me') }}
                                style={{ position: 'absolute', left: '30%', top: '20px' }}>
                                {/* 昵称 */}hello,<span> {JSON.parse(localStorage.getItem('user')).user_name}</span>
                                {/* 个性签名 */}
                                <div style={{ marginTop: '5px' }}>{JSON.parse(localStorage.getItem('user')).user_sign}</div>
                            </span>
                        </div>

                        {/* 添加动态的图像 */}
                        <div style={{ position: 'absolute', right: '5%', top: `${pxPage(20)}px` }}
                            onClick={() => this.props.history.push('/publish')}>
                            <i style={{ fontSize: '2.2em', color: '#cdcdcd' }} className="iconfont icon-add"></i>
                        </div>
                    </div>

                    <div className='mylist' style={{ width: '100%', margin: `${pxPage(70)}px 0px ${pxPage(50)}px 0px`, color: 'black' }}>
                        {/* 长列表尝试 */}
                        {/* 垃圾长列表 */}
                        <MyListView />
                    </div>
                    <Mytab />
                </div>
                <div style={{ flex: '1' }}></div>
            </div>
        )
    }
}

const mapStateToProps = (state) => {
    return {
        shop: state.shop,
        business: state.business,
        login: state.login,
        dynamic: state.dynamic
    }
}

export default withRouter(connect(mapStateToProps)(Community))